/**
 * lazyload
 */
var timer = null;
var cHeight = document.documentElement.clientHeight;
function lazyload(selector){
    let imgList = document.querySelectorAll(selector);
    let itemArray = Array.from(imgList).map(item=>{
        return{
            img : item,
            top : item.offsetTop,
            src : item.getAttribute("data-src")
        }
    })
    load(itemArray);
    window.addEventListener("scroll",load.bind(null, itemArray));
}
function load(itemArray){
    if(timer !== null) return;
    timer = setTimeout(()=>{
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
        var min = scrollTop + cHeight;
        itemArray.forEach(item => {
            if(item.top <= min){
                item.img.src = item.src;
            }
        });
        timer = null;
        
        
    },500)
}